<?php
/**
 * Created by PhpStorm
 * User: lcz
 * Date: 2019/10/29
 * Time: 11:55
 * 优惠券
 */

namespace app\api\controller;

use app\common\controller\Api;
use app\common\model\UserCoupon;

class Coupon extends Api {
	
	/**
	 * 我的优惠券
	 */
	public function my() {
		$userId = $this->auth->id;
		$model = new UserCoupon();
		
		$where['user_id'] = $userId;
		$status = $this->request->post('status');
		$status && $where['status'] = $status;
		$rows = $model->where($where)
			->field('id, status, name, `desc`, amount, from_unixtime(create_time, \'%Y/%m/%d %H:%i\') as create_time, from_unixtime(expired_time, \'%Y/%m/%d %H:%i\') as expired_time, min_amount')
			->select();
		$this->success('查询成功', $rows);
	}
}
